package acwing.bfs;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * 有向图的拓扑序列
 *
 * @author yang
 * @date 2021/11/29
 */
public class 有向图的拓扑序列 {

    static int N = 100010;
    static int[] h = new int [N];//存储所有单链表的头结点
    static int[] e = new int [N];//存储结点编号
    static int[] ne = new int [N];//存储下一个结点
    static int[] d = new int [N];//存储入度的数量
    static int[] top = new int [N];
    static Queue<Integer> q = new LinkedList<>();
    static int idx,n,count = 1;//count为top中有多少个元素

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int m = sc.nextInt();
        Arrays.fill(h, -1);
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            add(a, b);
            d[b]++; // 入度加一
        }
        if (topSort()) {
            for(int i = 1; i <= n; i ++) System.out.print(top[i] + " ");
        }
         else  System.out.print("-1");



    }

    private static boolean topSort() {
        for (int i = 1; i <= n; i++) {
            if(d[i] == 0) q.add(i);
        }
        while (!q.isEmpty()) {
            int t = q.poll();
            top[count] = t;
            count++;

            for (int i = h[t]; i != -1; i = ne[i]) {
                int j = e[i];
                if (--d[j] == 0) q.add(j);
            }
        }
        return count >= n;
    }

    private static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }


}
